package com.wanbatv.wanba.jianshencao.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.squareup.picasso.Picasso;
import com.wanbatv.wanba.jianshencao.R;
import com.wanbatv.wanba.jianshencao.api.ApiBuilder;
import com.wanbatv.wanba.jianshencao.api.ConfigUtils;
import com.wanbatv.wanba.jianshencao.entity.DownloadTask;
import com.wanbatv.wanba.jianshencao.util.AppUtil;
import com.wanbatv.wanba.jianshencao.util.Behavior;
import com.wanbatv.wanba.jianshencao.util.Crypto;
import com.wanbatv.wanba.jianshencao.util.DataReport;
import com.wanbatv.wanba.jianshencao.util.ProductInfo;
import com.wanbatv.wanba.jianshencao.util.TVViewPager;
import com.wanbatv.wanba.jianshencao.util.Util;
import com.wanbatv.wanba.jianshencao.utils.Product;
import com.wanbatv.wanba.jianshencao.utils.jsc_bean;
import com.wanbatv.wanba.jianshencao.view.LoginDemo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import com.wanbatv.wanba.jianshencao.broadcast.DownloadTaskReceiver;

import cn.ffcs.itvpay.ItvPayTask;


public class LoginActivity extends FullScreenActivity {
    // apk下载广播接收器
    DownloadTaskReceiver receiver;
    ProgressDialog progressDialog=null;
    public static int LANMU_NUM=0;
    static String device_id = Build.SERIAL;
    private TVViewPager viewpager;
    ArrayList<View> viewContainter = new ArrayList<View>();
    private DownAdapter mAdapter = null;
    ArrayList<View> viewContainter_geren = new ArrayList<View>();
    private TVViewPager viewpagerGeren;
    private DownAdapter_Geren mAdapter_geren = null;
    ArrayList<View> viewContainter_all = new ArrayList<View>();
    private TVViewPager viewpagerAll;
    private DownAdapter_All mAdapter_all = null;
    private TextView fit_main_time;
    //常量命名
    private static final int MSG_TIME = 1;
    private static final int POSITION_HOME = 0;
    private TextView allImg;
    private TextView personImg;
    private TextView threeImg;
    private TextView allText;
    private TextView personText;
    private TextView threeText;
    private Map<String,Bitmap> map=new HashMap<String,Bitmap>();
    private long exitTime;
    boolean[] personArray =new boolean[50];
    boolean[] allArray =new boolean[50];
    ImageView zdyFocus;
    ImageView mikeFocus;
    ImageView ruiFocus;
    ImageView jscFocus;
    public static boolean IS_DINGGOU =false;
    private String[] debugKey ={"KEYCODE_DPAD_UP","KEYCODE_DPAD_UP","KEYCODE_MENU"};
    private String[] userIdKey ={"KEYCODE_DPAD_UP","KEYCODE_DPAD_UP","KEYCODE_DPAD_UP"};
    private String[] payKey ={"KEYCODE_DPAD_DOWN","KEYCODE_DPAD_DOWN","KEYCODE_DPAD_DOWN"};
    private ConstantsRelease constantsRelease;
    private SwitchActivity apiSwitchActivity;
    private String debugMode;
    private String login_num;
    private String[] split1;
    private SwitchActivity displayId;
    private String fromweb;
    JSONArray zhifuArray =null;
    String orderInfo=null;
    private ArrayList<String> list_cover;
    private ArrayList<String> list_zy;
    private ArrayList<jsc_bean> list_bean;
    private LinearLayout homelinear;
    private SwitchActivity paySwitchActivity;
    private String zhifu;
    private String payIp;
    private String pay_url;
    private String payEncrypt;
    LoginDemo zdyView,mikeView,ruiView,jscView;
    HashMap<String, String> param;
    private static int MSG_UPDATE=111;

    //todo 修改命名
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        Behavior.onAppStart(LoginActivity.this);
        DataReport.AppRetreat(this,"1000");
        dinggou();
        //updateAPK("http://121.201.7.173:8067/wanba_shzg/apk_update_jianshencao.jsp", AppUtil.converVersionNameToInt(AppUtil.getAppVersionName(this)));
        updateAPK("http://61.191.46.214:8080/wanba_shzg/apk_update_jianshencao.jsp",
                AppUtil.converVersionNameToInt(AppUtil.getAppVersionName(this)));
        //继承activity用activity结尾命名
        //命名 key
        apiSwitchActivity = new SwitchActivity(debugKey,"zhengshi","ceshi");
        displayId = new SwitchActivity(userIdKey);
        paySwitchActivity = new SwitchActivity(payKey);
        for (int i = 0; i< personArray.length; i++){
            personArray[i]=false;
        }
        for (int i = 0; i< allArray.length; i++){
            allArray[i]=false;
        }
        //接口数据切换
        constantsRelease = new ConstantsRelease();



        login_num = constantsRelease.login_num;

        //统一命名
        payIp = "61.191.45.118";
        //pay_url="http://61.191.45.118:7002/itv-api\"+\"/has_order?providerId=\"+\"shzg\"+\"&orderInfo=";
        payEncrypt = "26f545c0d092463185acdd3e2c73fdda";

        viewpager=(TVViewPager)findViewById(R.id.viewpager);

        allImg =(TextView)findViewById(R.id.login_tv1);
        personImg =(TextView)findViewById(R.id.login_tv2);
        threeImg =(TextView)findViewById(R.id.login_tv3);
        allText =(TextView)findViewById(R.id.login_tv11);

        /*personText =(TextView)findViewById(R.id.login_tv21);
        threeText =(TextView)findViewById(R.id.login_tv31);*/

        list_bean=new ArrayList<>();
        list_cover=new ArrayList<>();
        list_zy=new ArrayList<>();

        fit_main_time=(TextView)findViewById(R.id.fit_main_time);
        //首页右上角时间功能
        new TimeThread().start();
        //命名
        final View pageHome = LayoutInflater.from(LoginActivity.this).inflate(R.layout.page_shouye, null);
        View pagePerson = LayoutInflater.from(LoginActivity.this).inflate(R.layout.page_person, null);
        ViewGroup pageThree = (ViewGroup) LayoutInflater.from(LoginActivity.this).inflate(
                R.layout.page_three, null);
        View pageHomeZy = LayoutInflater.from(LoginActivity.this).inflate(R.layout.page_shouye2, null);
        homelinear = ((LinearLayout) pageHomeZy.findViewById(R.id.linear));

        viewContainter.add(pageHomeZy);
        /*viewContainter.add(pagePerson);
        viewContainter.add(pageThree);*/



        getlist();
        //hdbg = ((ImageView) pageThree.findViewById(R.id.huodongbg));
        //Glide.with(getApplicationContext()).load("http://61.191.46.214:8080/activity/huodong.png").skipMemoryCache(true).into(hdbg);

        //首页人数
        RequestQueue homeNum = Volley.newRequestQueue(LoginActivity.this.getApplicationContext());
        JsonObjectRequest request_zi = new JsonObjectRequest(login_num, null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj=jsonObject.getJSONObject("data");
                            JSONArray arr=obj.getJSONArray("list");
                            zdyView=(LoginDemo)pageHome.findViewById(R.id.login_demo1);
                            //LoginDemo d2=(LoginDemo)v1.findViewById(R.id.login_demo2);
                            mikeView=(LoginDemo)pageHome.findViewById(R.id.login_demo3);
                            ruiView=(LoginDemo)pageHome.findViewById(R.id.login_demo4);
                            jscView=(LoginDemo)pageHome.findViewById(R.id.login_demo5);
                            TextView zdyNum=(TextView)zdyView.findViewById(R.id.login_demo_tv);
                            //TextView tv2=(TextView)d2.findViewById(R.id.login_demo_tv);
                            TextView mikeNum=(TextView)mikeView.findViewById(R.id.login_demo_tv);
                            TextView ruiNum=(TextView)ruiView.findViewById(R.id.login_demo_tv);
                            TextView jscNum=(TextView)jscView.findViewById(R.id.login_demo_tv);
                            for (int i=0;i<arr.length();i++){
                                JSONObject objNum=arr.getJSONObject(i);
                                String category=objNum.getString("category");
                                int currtotal=objNum.getInt("currtotal");
                                //放到资源文件中
                                if(category.equals("101")){
                                    mikeNum.setText("当前人数"+currtotal+"人");
                                }else if(category.equals("103")){
                                    zdyNum.setText("当前人数"+currtotal+"人");
                                }
                                else if(category.equals("102")){
                                    ruiNum.setText("当前人数"+currtotal+"人");
                                }
                                else if(category.equals("106")){
                                    jscNum.setText("当前人数"+currtotal+"人");
                                } else if(category.equals("110")){
                                    //tv2.setText("当前人数"+currtotal+"人");
                                }else{

                                }
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
            }
        }

        );
        request_zi.setRetryPolicy(new DefaultRetryPolicy(30000,3,1.0f));
        homeNum.add(request_zi);


        viewpagerAll =(TVViewPager)pagePerson.findViewById(R.id.login_zhongxin_all_viewpager);
        viewpagerGeren =(TVViewPager)pagePerson.findViewById(R.id.login_zhongxin_geren_viewpager);
        mAdapter=new DownAdapter();
        viewpager.setAdapter(mAdapter);
        viewpager.setOffscreenPageLimit(1);
        viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {

                //todo 数字常量  命名
                if (i == POSITION_HOME) {
                    allText.setTextColor(Color.parseColor("#fff799"));
                    personText.setTextColor(Color.parseColor("#ffc49c"));
                    threeText.setTextColor(Color.parseColor("#ffc49c"));
                    allImg.setBackgroundResource(R.drawable.login_top2);
                    personImg.setBackgroundResource(R.drawable.login_top3);
                    threeImg.setBackgroundResource(R.drawable.login_top3);

                    Behavior.onPagePause(LoginActivity.this,100001,"全部运动");
                    DataReport.PageRetreat(LoginActivity.this,"1100","100010");
                }
                /*if (i == POSITION_PERSON) {
                    personText.setTextColor(Color.parseColor("#fff799"));
                    allText.setTextColor(Color.parseColor("#ffc49c"));
                    threeText.setTextColor(Color.parseColor("#ffc49c"));
                    personImg.setBackgroundResource(R.drawable.login_top2);
                    allImg.setBackgroundResource(R.drawable.login_top3);
                    threeImg.setBackgroundResource(R.drawable.login_top3);
                    if(personText.isFocused()){

                    }else{

                    }
                    Behavior.onPagePause(LoginActivity.this,100001,"个人中心");
                    DataReport.PageRetreat(LoginActivity.this,"1100","100011");
                }
                if (i == POSITION_HUODONG) {
                    threeText.setTextColor(Color.parseColor("#fff799"));
                    personText.setTextColor(Color.parseColor("#ffc49c"));
                    allText.setTextColor(Color.parseColor("#ffc49c"));
                    threeImg.setBackgroundResource(R.drawable.login_top2);
                    personImg.setBackgroundResource(R.drawable.login_top3);
                    allImg.setBackgroundResource(R.drawable.login_top3);
                    yema_num=3;
                    Behavior.onPagePause(LoginActivity.this,100001,"微信相册");
                    DataReport.PageRetreat(LoginActivity.this,"1100","100012");
                }*/
            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });
        allText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    v.setBackgroundResource(R.drawable.main_title_background_focused);
                    viewpager.setCurrentItem(0);

                } else {
                   v.setBackgroundResource(R.drawable.fittime_guangbiao_tm);

                }
            }
        });
        /*personText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    v.setBackgroundResource(R.drawable.main_title_background_focused);
                    viewpager.setCurrentItem(1);

                } else {
                    v.setBackgroundResource(R.drawable.fittime_guangbiao_tm);

                }
            }
        });
        threeText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    v.setBackgroundResource(R.drawable.main_title_background_focused);
                    viewpager.setCurrentItem(2);
                }else{
                    v.setBackgroundResource(R.drawable.fittime_guangbiao_tm);

                }
            }
        });*/




        zdyView = (LoginDemo)pageHome.findViewById(R.id.login_demo1);
       // LoginDemo demo2 = (LoginDemo)v1.findViewById(R.id.login_demo2);
        mikeView = (LoginDemo)pageHome.findViewById(R.id.login_demo3);
        ruiView = (LoginDemo)pageHome.findViewById(R.id.login_demo4);
        jscView = (LoginDemo)pageHome.findViewById(R.id.login_demo5);


       // ImageView demo1_iv2=(ImageView)demo2.findViewById(R.id.login_demo_iv1);
        ImageView mikeImg =(ImageView)mikeView.findViewById(R.id.login_demo_iv1);
        ImageView ruiImg  =(ImageView)ruiView.findViewById(R.id.login_demo_iv1);
        ImageView jscImg  =(ImageView)jscView.findViewById(R.id.login_demo_iv1);

        zdyFocus =(ImageView)zdyView.findViewById(R.id.login_demo_iv2);
       // demo2_iv2=(ImageView)demo2.findViewById(R.id.login_demo_iv2);
        mikeFocus =(ImageView)mikeView.findViewById(R.id.login_demo_iv2);
        ruiFocus =(ImageView)ruiView.findViewById(R.id.login_demo_iv2);
        jscFocus =(ImageView)jscView.findViewById(R.id.login_demo_iv2);


        zdyFocus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it=new Intent();
                it.setClass(LoginActivity.this,ZhengdyActivity.class);
                startActivity(it);
                Behavior.onEvent(LoginActivity.this, 3020103, "点击郑多燕");
            }
        });
       /* demo2_iv2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it=new Intent();
                it.setClass(LoginActivity.this,FittimeActivity.class);
                startActivity(it);
                Behavior.onEvent(LoginActivity.this, 3020110, "点击fittime");
            }
        });*/
        mikeFocus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it=new Intent();
                it.setClass(LoginActivity.this,MikeLingChannelActivity.class);
                startActivity(it);
                Behavior.onEvent(LoginActivity.this, 3020101, "点击麦克林");
            }
        });
        ruiFocus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it=new Intent();
                it.setClass(LoginActivity.this,RuijianChannelActivity.class);
                startActivity(it);
                Behavior.onEvent(LoginActivity.this, 3020102, "点击睿建");
            }
        });
        jscFocus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it=new Intent();
                it.setClass(LoginActivity.this,JianshencaoChannelActivity.class);
                startActivity(it);
                Behavior.onEvent(LoginActivity.this, 3020106, "点击健身操");
            }
        });

        //demo1_iv2.setImageResource(R.drawable.login_tupian2);
        mikeImg.setImageResource(R.drawable.login_tupian3);
        ruiImg.setImageResource(R.drawable.login_tupian4);
        jscImg.setImageResource(R.drawable.login_tupian5);



        initProductInfo(new ProductInitCallback() {
            @Override
            public void afterProductInited() {
                int region = ProductInfo.getInstance().region;
                RequestQueue rq = Volley.newRequestQueue(LoginActivity.this.getApplicationContext());

                String url = new ApiBuilder(ConfigUtils.Channel.CID_CURRENT)
                        .atPort(ConfigUtils.Port.CHECKIN)
                        .withApi(ConfigUtils.Api.CHECKIN_GET_TOTAL)
                        .addParam("deviceid", device_id)
                        .addParam("region", region)
                        .create();
                JsonObjectRequest request = new JsonObjectRequest(
                        url, null,
                        new Response.Listener<JSONObject>() {

                            @Override
                            public void onResponse(JSONObject jsonObject) {
                                try {
                                    JSONObject obj = jsonObject.getJSONObject("result");
//										rank.setText(device_id);

                                    int num_time = obj.getInt("durationTotal");
                                    int m = num_time / 60 % 60;
                                    int h = m / 60;
//                                    View v1 = viewContainer.get(0);
//                                    TextView allTime = (TextView) v1.findViewById(R.id.all_time);
//                                    TextView allCalorie = (TextView) v1.findViewById(R.id.all_calorie);
//                                    allTime.setText(h + "小时" + m + "分钟");
//
//                                    int kaluli = num_time / 10;
//                                    allCalorie.setText(kaluli + "大卡");

                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                            }
                        }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                    }
                }

                );
                rq.add(request);
            }
        });
        /*RequestQueue rq_jilu = Volley.newRequestQueue(LoginActivity.this.getApplicationContext());

        String url = new ApiBuilder(ConfigUtils.Channel.CID_CURRENT)
                .atPort(ConfigUtils.Port.CHECKIN)
                .withApi(ConfigUtils.Api.CHECKIN_GET_TOTAL)
                .addParam("deviceid", Util.getDeviceId(LoginActivity.this))
                .addParam("region",23)
                .create();
        JsonObjectRequest request_jilu = new JsonObjectRequest(
                url, null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj = jsonObject.getJSONObject("result");
//										rank.setText(device_id);

                            int num_time = obj.getInt("durationTotal");
                            int m = num_time / 60 % 60;
                            int h = m / 60;
                            View v1=viewContainter.get(0);
                            TextView allTime_h = (TextView)v1.findViewById(R.id.page1_iv1);
                            TextView allTime_m = (TextView)v1.findViewById(R.id.page1_iv2);
                            TextView allCalorie = (TextView)v1.findViewById(R.id.page1_iv3);
                            allTime_h.setText(h+"");
                            allTime_m.setText(m+"");
                            int kaluli=num_time*355/3600;
                            allCalorie.setText(kaluli+"");
                            View v2=viewContainter.get(1);
                            TextView allTime_h1 = (TextView)v2.findViewById(R.id.login_zhongxin_tv1);
                            TextView allTime_m1 = (TextView)v2.findViewById(R.id.login_zhongxin_tv2);
                            TextView allCalorie1 = (TextView)v2.findViewById(R.id.login_zhongxin_tv3);
                            TextView now_paiming = (TextView)v2.findViewById(R.id.login_zhongxin_tv4);
                            TextView pass = (TextView)v2.findViewById(R.id.login_zhongxin_tv5);
                            allTime_h1.setText(h+"");
                            allTime_m1.setText(m+"");
                            allCalorie1.setText(kaluli+"");
                            now_paiming.setText(obj.getInt("rank")+"");
                            pass.setText(obj.getInt("surpassed")+"%");
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
            }
        }

        );
        request_jilu.setRetryPolicy(new DefaultRetryPolicy(30000,3,1.0f));
        rq_jilu.add(request_jilu);*/
        yulanceshi();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_login, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
    private class DownAdapter extends PagerAdapter {
        @Override
        public int getCount() {
            return viewContainter.size();
        }

        //滑动切换的时候销毁当前的组件
        @Override
        public void destroyItem(ViewGroup container, int position,
                                Object object) {
            ((ViewPager) container).removeView(viewContainter.get(position));
        }

        //每次滑动的时候生成的组件
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            ((ViewPager) container).addView(viewContainter.get(position));
            return viewContainter.get(position);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public int getItemPosition(Object object) {
            return super.getItemPosition(object);
        }


    }
    private class DownAdapter_Geren extends PagerAdapter {
        @Override
        public int getCount() {
            return viewContainter_geren.size();
        }

        //滑动切换的时候销毁当前的组件
        @Override
        public void destroyItem(ViewGroup container, int position,
                                Object object) {
            ((ViewPager) container).removeView(viewContainter_geren.get(position));
        }

        //每次滑动的时候生成的组件
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            ((ViewPager) container).addView(viewContainter_geren.get(position));
            return viewContainter_geren.get(position);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public int getItemPosition(Object object) {
            return super.getItemPosition(object);
        }


    }
    private class DownAdapter_All extends PagerAdapter {
        @Override
        public int getCount() {
            return viewContainter_all.size();
        }

        //滑动切换的时候销毁当前的组件
        @Override
        public void destroyItem(ViewGroup container, int position,
                                Object object) {
            ((ViewPager) container).removeView(viewContainter_all.get(position));
        }

        //每次滑动的时候生成的组件
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            ((ViewPager) container).addView(viewContainter_all.get(position));
            return viewContainter_all.get(position);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public int getItemPosition(Object object) {
            return super.getItemPosition(object);
        }


    }

    public class TimeThread extends Thread {
        @Override
        public void run () {
            do {
                try {
                    Thread.sleep(1000);
                    Message msg = new Message();
                    msg.what = MSG_TIME;
                    mHandler.sendMessage(msg);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            } while(true);
        }
    }
    private void initProductInfo(final ProductInitCallback callback) {
        RequestQueue rq = Volley.newRequestQueue(this);
        String url = new ApiBuilder(ConfigUtils.Channel.CID_CURRENT)
                .withApi(ConfigUtils.Api.PRODUCT_INFO)
                .create();
        JsonObjectRequest request = new JsonObjectRequest(url, null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        ProductInfo.getInstance().init(jsonObject);

                        if (callback != null) {
                            callback.afterProductInited();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        });
        request.setRetryPolicy(new DefaultRetryPolicy(30000,3,1.0f));
        rq.add(request);
    }
    private interface ProductInitCallback {
        void afterProductInited();
    }
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage (Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case MSG_TIME:
                    long sysTime = System.currentTimeMillis();
                    CharSequence sysTimeStr = DateFormat.format("hh:mm aa", sysTime);
                    fit_main_time.setText(sysTimeStr);
                    break;

                default:
                    break;
            }
        }
    };
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        apiSwitchActivity.match(keyCode,this);
        displayId.display(keyCode,this);
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            // 2秒之内连续点击两次back就退出app


            if (System.currentTimeMillis() - exitTime > 2000) {
                System.out.println(Toast.LENGTH_LONG);
                Toast.makeText(this, "再按一次退出玩吧", Toast.LENGTH_LONG).show();
                exitTime = System.currentTimeMillis();
            } else {
                //传值 命名
                if (fromweb.equals("fromqq")){
                    Intent intent = new Intent(getApplicationContext(), WebActivity.class);
                    startActivity(intent);
                    finish();
                }else if (fromweb.equals("nullqq")){
                    Behavior.onAppEnd(LoginActivity.this);
                    finish();
                }else {
                    finish();
                }

            }

            return true;
        }
        //合成  或
        else if(zdyFocus.isFocused() && keyCode==KeyEvent.KEYCODE_DPAD_UP){
            allText.requestFocus();
            return true;
        }
        else if(mikeFocus.isFocused() && keyCode==KeyEvent.KEYCODE_DPAD_UP){
            allText.requestFocus();
            return true;
        }
        else if(ruiFocus.isFocused() && keyCode==KeyEvent.KEYCODE_DPAD_UP){
            allText.requestFocus();
            return true;
        }

        else if(jscFocus.isFocused() && keyCode==KeyEvent.KEYCODE_DPAD_UP){
            allText.requestFocus();
            return true;
        }
        else {
            return super.onKeyDown(keyCode, event);
        }

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        //Loginpage3.onActivityDestory();
        Iterator iter = map.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next(); Object key = entry.getKey();
            Object val = entry.getValue();
            Bitmap a=(Bitmap)val;
            a.recycle();
        }
        System.gc();
        DataReport.AppRetreat(this,"2000");
    }

    @Override
    protected void onResume() {
        super.onResume();
        // 检查最新的apk版本并提示是否下载

        fromweb = getIntent().getStringExtra("fromweb")+"qq";
        if (!getSharedPreferences("apk_update", 0).getBoolean("is_update",
                false)) {
            getSharedPreferences("apk_update", 0).edit()
                    .putBoolean("is_update", true).commit();
//			updateAPK(getResources().getString(R.string.apk_update_json_url),
//					AppUtil.converVersionNameToInt(AppUtil.getAppVersionName(this)));

        }
    }
    /**
     * 更新apk
     *
     * @param url
     */
    private void updateAPK(String url, final int currVersion) {
        receiver = new DownloadTaskReceiver();
        JsonObjectRequest mJsonObjectRequest = new JsonObjectRequest(url, null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject obj) {
                        try {
                            JSONObject response=obj.getJSONObject("data");
                            // 版本是否更新 0否 1是
                            String versionName = response.getString("versionName");
                            if (AppUtil.converVersionNameToInt(versionName) > currVersion) {
                                // 获取apk下载地址
                                final String apkUpdateUrl = response
                                        .getString("apk");
                                // 是否强制更新 0否 1是
                                int isForceUpdate = response
                                        .getInt("isForce");


                                AlertDialog.Builder builder = new AlertDialog.Builder(
                                        LoginActivity.this)
                                        .setTitle("提示")
                                        .setMessage("升级到最新版本")
                                        .setPositiveButton(
                                                "确定",
                                                new AlertDialog.OnClickListener() {
                                                    public void onClick(
                                                            DialogInterface dialog,
                                                            int which) {
                                                        /*Toast.makeText(
                                                                LoginActivity.this,
                                                                "进行更新！",
                                                                Toast.LENGTH_LONG)
                                                                .show();*/
                                                        showprogress(apkUpdateUrl);
                                                        /*download("",
                                                                apkUpdateUrl,
                                                                "wanba",
                                                                "", 0);*/
                                                    }
                                                });

                                if (isForceUpdate == 0) {
                                    builder.setNegativeButton("取消",
                                            new AlertDialog.OnClickListener() {

                                                @Override
                                                public void onClick(
                                                        DialogInterface dialog,
                                                        int which) {
                                                    dialog.dismiss();
                                                }
                                            });
                                    builder.setCancelable(true);
                                } else {
                                    builder.setCancelable(false);
                                }
                                builder.create();
                                builder.show();
                            }

                        } catch (NumberFormatException e) {
                            e.printStackTrace();
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(LoginActivity.this, "更新访问失败！",
                        Toast.LENGTH_LONG).show();
            }
        });

        // 将 请求放入 请求队列
        AppUtil.getInstance(this).getRequestQueue().add(mJsonObjectRequest);

    }
    private void showprogress(final String url){
        progressDialog = new ProgressDialog(LoginActivity.this);
        progressDialog.setMessage("正在下载");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.show();
        new Thread(new Runnable() {
            @Override
            public void run() {
                open(downFile(url));
            }
        }).start();

    }
    private void ordered(){
        AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
        builder.setMessage("您已订购过该产品");
        builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
            }
        }).create();
        builder.show();
    }

    /**
     * 下载app具体操作
     *
     * @param appId
     * @param downloadUrl
     * @param appName
     * @param appDesc
     * @param appSize
     */
    public void download(String appId, String downloadUrl, String appName,
                         String appDesc, long appSize) {
        // 初始化DownloadTask实例
        DownloadTask aDownloadTask = new DownloadTask(appId,
                Uri.parse(downloadUrl), appName, appDesc, appSize);
        // 实例化DownloadManager.Request
        DownloadManager.Request request = new DownloadManager.Request(
                aDownloadTask.getDownloadURI());
        // 系统下载路径
        request.setDestinationInExternalFilesDir(LoginActivity.this,
                Environment.DIRECTORY_DOWNLOADS, appName + ".apk");

        // request.setShowRunningNotification(true);
        // 向队列加载一个新的下载项
        DownloadManager downloadManager = ((DownloadManager) LoginActivity.this
                .getSystemService(Activity.DOWNLOAD_SERVICE));
        long downloadId = downloadManager.enqueue(request);
        // 保存downloadId
        aDownloadTask.setDownloadId(downloadId);
        // 保存DownloadTask对象
        // tasks.add(aDownloadTask);
        // 过滤器 当前下载任务完成

    }
    private void chanpinbao(){
        RequestQueue rq_2 = Volley.newRequestQueue(getApplicationContext());
        final JsonObjectRequest request_2 = new JsonObjectRequest("http://61.191.46.214:8087/getapi/common/subjects/31259d2c48bec6a1ba589360c748e132?flavor="+ Product.flavor, null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj=jsonObject.getJSONObject("data");
                            JSONArray arr=obj.getJSONArray("list");
                            zhifuArray =arr;
                            //Toast.makeText(getApplicationContext(),obj+"@@",Toast.LENGTH_LONG).show();
                            dingdanhao();
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                Toast.makeText(getApplicationContext(),"请求产品包超时，请检查网络并返回重试。",Toast.LENGTH_SHORT).show();

            }
        }

        ) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                PackageInfo pi= null;
                try {
                    pi = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0);
                    headers.put("accept", "applicationnd.wanba.wanbatv.com.wudao;version="+pi.versionName);
                    headers.put("app_version", pi.versionName);
                    headers.put("app_package_name",pi.packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }


                // MyLog.d(TAG, "headers=" + headers);
                return headers;
            }
        };
        request_2.setRetryPolicy(new DefaultRetryPolicy(30000,3,1.0f));

        rq_2.add(request_2);
    }
    private  void dingdanhao(){

        try {
            JSONObject obj = zhifuArray.getJSONObject(0);
            final   String subject=obj.getString("subject");
            final   String subjectId=obj.getString("subjectId");
            final   String price=obj.getString("price");
            //Toast.makeText(getApplicationContext(),obj+"==",Toast.LENGTH_SHORT).show();
            RequestQueue requestQueue = Volley.newRequestQueue(LoginActivity.this);
            String url="http://61.191.46.214:8087/postapi/common/wpay/getorder";
            StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.POST,url,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {

                            try {

                                JSONObject objZhifubao = (JSONObject) new JSONTokener(response).nextValue();
                                //Toast.makeText(getApplicationContext(),obj_zhifubao+"  @  @  "+Util.getDeviceId(getApplicationContext()),Toast.LENGTH_LONG).show();
                                JSONObject oobj=objZhifubao.getJSONObject("data");
                                String order=oobj.getString("order");
                                orderInfo="orderId="+order+"|itvAccount="+ AppUtil.STB.UserID+"|productId=zg_wanba"+"|price=1500";
                                orderInfo=jiami(orderInfo);
                                Log.d("@ricardo@", "get subject "+objZhifubao);
                                ItvPayTask itvPayTask = new ItvPayTask(LoginActivity.this);
                                HashMap<String, String> data = new HashMap<String, String>();
                                data.put(ItvPayTask.NET_IP, payIp);//访问地址ip 测试ip为61.191.45.116 正式为//61.191.45.118
                                data.put(ItvPayTask.NET_PORT, "7002");//访问地址端口
                                data.put(ItvPayTask.DEVICEMODEL, AppUtil.STB.Model);//机顶盒信息
                                //	data.put(ItvPayTask.RETURNURL, "http://61.191.46.214:8087/getapi/common/wpay/result/ahpay/");//同步返回地址
                                data.put(ItvPayTask.NOTIFYURL, "http://172.16.33.228:8087/postapi/common/wpay/paynotify/ahpay/"+AppUtil.STB.UserID);//异步通知地址
                                data.put(ItvPayTask.DEVICETYPE, "hd");//机顶盒信息
                                data.put(ItvPayTask.USERAGENT, "wanba");//机顶盒信息
                                data.put(ItvPayTask.DEVICESERIALNO, AppUtil.STB.Sn);//机顶盒信息
                                data.put(ItvPayTask.IP, AppUtil.STB.IP);//机顶盒信息
                                data.put(ItvPayTask.ORDERINFO, orderInfo);//订单信息
                                data.put(ItvPayTask.PROVIDERID, "shzg");//供应商id
                                itvPayTask.pay(data);

                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }
                    }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(getApplicationContext(),"请求订单号超时，请检查网络并返回重试。",Toast.LENGTH_SHORT).show();

                    error.printStackTrace();
                }
            }) {
                @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    HashMap<String, String> headers = new HashMap<String, String>();
                    PackageInfo pi= null;
                    try {
                        pi = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0);
                        headers.put("accept", "applicationnd.com.wanbatv.wanba.jianshencao;version="+pi.versionName);
                        headers.put("app_version", pi.versionName);
                        headers.put("app_package_name",pi.packageName);
                    } catch (PackageManager.NameNotFoundException e) {
                        e.printStackTrace();
                    }


                    // MyLog.d(TAG, "headers=" + headers);
                    return headers;
                }
                @Override
                public String getBodyContentType() {
                    return "application/x-www-form-urlencoded; charset=" + getParamsEncoding();
                }
                @Override
                protected Map<String, String> getParams() {
                    //在这里设置需要post的参数
                    HashMap<String, String> params = new HashMap<String, String>();
                    params.put("partner","");
                    params.put("subject", subject);
                    params.put("subjectid",subjectId);
                    params.put("price",price);
                    params.put("provider","ahpay");
                    params.put("stb", Util.getDeviceId(getApplicationContext()));
                    params.put("flavor", Product.flavor);

                    return params;
                }
            };
            stringRequest.setRetryPolicy(new DefaultRetryPolicy(30000,3,1.0f));
            requestQueue.add(stringRequest);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    private  String jiami(String orderInfo){

        String jiami= Crypto.TripleDES.encrypt(orderInfo, "26f545c0d092463185acdd3e2c73fdda");
//        String jiami=Crypto.TripleDES.decrypt(jiami,"36161889369a412b923af17dafb0fe88");
        Log.e("jiami",jiami);
//        Log.e("jiemi",jiemi);
        return jiami;
    }

    private void dinggou(){

        String infoEncrypt = "itvAccount="+AppUtil.STB.UserID+"|"+"productId=zg_wanba";
        String orderInfo=jiami(infoEncrypt);

        try {
            orderInfo= URLEncoder.encode(orderInfo,"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        String url="http://61.191.45.118:7002/itv-api"+"/has_order?providerId="+"shzg"+"&orderInfo="+orderInfo;
        RequestQueue rq = Volley.newRequestQueue(LoginActivity.this.getApplicationContext());
        StringRequest request=new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.e("response:",response);
                try {
                    JSONObject obj = new JSONObject(response);
                    int num=obj.getInt("ordered");
                    if(num!=0){
                        IS_DINGGOU =true;
                    }else {
                        IS_DINGGOU =false;
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        });
        rq.add(request);


    }
    String  extraKey=null;
    @Override
    protected void onStart() {
        super.onStart();
        IntentFilter filter = new IntentFilter(
                DownloadManager.ACTION_DOWNLOAD_COMPLETE);
        // 注册并监听过滤器
        registerReceiver(receiver, filter);

    }

    @Override
    protected void onStop() {
        super.onStop();
        unregisterReceiver(receiver);
        extraKey=null;

    }

    public File downFile(String str){
        Log.d("ricardo","downfile");
        File file = new File(getFilesDir() + "/jsc.apk");
        if (file.exists()){
            if (file.isFile()){
                file.delete();
            }
        }
        String fileName="jsc.apk";
        //保存地址不要写死 用系统路径 data目录下
        File filesDir = getApplicationContext().getFilesDir();
        String permission="666";
        try {
            String command="chmod "+permission+" "+filesDir;
            Runtime runtime = Runtime.getRuntime();
            runtime.exec(command);
        }catch (IOException e){
            e.printStackTrace();
        }
        Log.d("ricardo",filesDir+"");
        FileOutputStream os=null;
        InputStream is=null;
        if (!filesDir.exists()){
            filesDir.mkdir();
        }
        File fileApk = new File(filesDir + "/jsc.apk");
        Log.d("ricardo","@@"+fileApk);
        try {
            URL url = new URL(str);
            HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            long fileLength = httpURLConnection.getContentLength();
            is = httpURLConnection.getInputStream();
            os = getApplicationContext().openFileOutput("jsc.apk",MODE_WORLD_READABLE|MODE_WORLD_WRITEABLE);
            int length;
            int readLength=0;
            byte[] buffer = new byte[2*1024*1024];
            while((length = is.read(buffer)) != -1){
                os.write(buffer, 0, length);
                readLength+=length;
                int current = (int) (((float) readLength / fileLength) * 100);
                //主线程刷新
                progressDialog.setProgress(current);
                Thread.sleep(100);
                os.flush();
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            if (is!=null){
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (os!=null){
                try {
                    os.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        Log.d("ricardo","已经下载完成");
        return fileApk;

    }
    public void open(File file){
        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive");
        startActivity(intent);
        startActivity(intent);
        Process.killProcess(Process.myPid());
    }

    public void yulanceshi(){
        extraKey=this.getIntent().getStringExtra("which");
        //wudao = getIntent().getStringExtra("wudao");
        //Toast.makeText(getApplicationContext(),extraKey+"@@",Toast.LENGTH_LONG).show();
        Log.d("@@yulan",extraKey+"qq");
        if (extraKey!=null){
            switch (extraKey){
                case "zdy":
                    toActivity(getApplicationContext(),ZhengdyActivity.class);
                    break;
                case "mike":
                    toActivity(getApplicationContext(),MikeLingChannelActivity.class);
                    break;
                case "ruijian":
                    toActivity(getApplicationContext(),RuijianChannelActivity.class);
                    break;
                case "jianshencao":
                    toActivity(getApplicationContext(),JianshencaoChannelActivity.class);
                    break;
                case "huodong":
                    toActivity(getApplicationContext(),WebActivity.class);
                    finish();
                    break;
                default:
                    split1 = extraKey.split(",");
                    String play_url = split1[1];
                    String content_code = split1[2];
                    String cate_code = split1[3];
                    String cate_name = split1[4];
                    String title_lanmu = split1[5];
                    Intent intent=new Intent(getApplicationContext(),SimplePlayerActivity.class);
                    intent.putExtra("abc","sim");
                    intent.putExtra("play_url",play_url);
                    intent.putExtra("content_code",content_code);
                    intent.putExtra("cate_code",cate_code);
                    intent.putExtra("cate_name",cate_name);
                    intent.putExtra("title_lanmu",title_lanmu);
                    startActivity(intent);
                    break;
            }
        }
    }
    public void toActivity(Context context,Class className){
        Intent intent = new Intent(context, className);
        startActivity(intent);
    }
    public void homeJson(JSONObject response){

        Log.d("ricardo","respone == "+response);
        try {
            JSONObject data = response.getJSONObject("data");
            JSONArray array = data.getJSONArray("list");
            JSONObject jsonObject1 = array.getJSONObject(0);
            String title1 = jsonObject1.getString("title");
            int cate_code1 = jsonObject1.getInt("cate_code");
            String cover_url1 = jsonObject1.getString("cover");
            String cate_url1 = jsonObject1.getString("cate_url");
            list_cover.add(cover_url1);
            list_zy.add(cate_url1);
            for (int i = 2; i < array.length(); i++) {
                JSONObject jsonObject = array.getJSONObject(i);
                String title = jsonObject.getString("title");
                int cate_code = jsonObject.getInt("cate_code");
                String cover_url = jsonObject.getString("cover");
                String cate_url = jsonObject.getString("cate_url");
                list_cover.add(cover_url);
                list_zy.add(cate_url);
                String background_url = jsonObject.getString("background");
                jsc_bean beanfor = new jsc_bean();
                beanfor.setTitle(title);
                beanfor.setCate_code(cate_code);
                beanfor.setBackground_url(background_url);
                list_bean.add(beanfor);
            }
        }catch (JSONException e){
            e.printStackTrace();
        }
    }
    public void getlist(){
        RequestQueue rq_shouye = Volley.newRequestQueue(getApplicationContext());
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest("http://61.191.46.214:8080/wanba_shzg/ott_main_jsc.jsp", null,
                new Response.Listener<JSONObject>() {


                    @Override
                    public void onResponse(JSONObject response) {
                            homeJson(response);
                            for (int i=0;i<4;i++){
                                LoginDemo loginDemo = new LoginDemo(getApplicationContext());
                                ImageView img = (ImageView) loginDemo.findViewById(R.id.login_demo_iv1);
                                ImageView cover = (ImageView) loginDemo.findViewById(R.id.login_demo_iv2);
                                Picasso.with(getApplicationContext()).load(list_cover.get(i)).into(img);
                                homelinear.addView(loginDemo);
                                switch (i){
                                    //数字常量
                                    case 0:
                                        cover.setOnClickListener(new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                //跳转
                                                toActivity(getApplicationContext(),ZhengdyActivity.class);
                                            }
                                        });
                                        break;
                                    case 1:
                                        cover.setOnClickListener(new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                toActivity(getApplicationContext(),MikeLingChannelActivity.class);
                                            }
                                        });
                                        break;
                                    case 2:
                                        cover.setOnClickListener(new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                toActivity(getApplicationContext(),RuijianChannelActivity.class);
                                            }
                                        });
                                        break;
                                    case 3:
                                        cover.setOnClickListener(new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                toActivity(getApplicationContext(),JianshencaoChannelActivity.class);
                                            }
                                        });
                                        break;
                                    /*default:
                                        final int finalI = i;
                                        cover.setOnClickListener(new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {

                                                String bgurl=list_bean.get(finalI).getBackground_url();
                                                String zyurl=list_zy.get(finalI);
                                                Log.d("ricardo",finalI+"  @@  "+list_bean.size()+" @@ "+zyurl);
                                                param = new HashMap<>();
                                                param.put("background_url",bgurl);
                                                param.put("zyurl",zyurl);
                                                new OpenActivityAction(getApplicationContext(),ZhangyuActivity.class,param).onClick(view);
                                            }
                                        });
                                        break;*/

                                }

                            }

                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        });
        jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(3000,3,1.0f));
        rq_shouye.add(jsonObjectRequest);
    }
}
